package LeetCode.leetcode455;

import java.util.Arrays;

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int startIndex = 0;
        int result = 0;
        for (int i = 0; i < s.length; i++) {
            for (int j = startIndex; j < g.length; j++) {
                if (s[i] >= g[j]){
                    result++;
                    startIndex=j+1;
                    break;
                }
            }
        }
        return result;
    }
}
